<?php

use yii\db\Migration;

/**
 * Class m190912_055740_auth_group
 */
class m190912_055740_auth_group extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="角色权限表"';
        $this->createTable('{{%auth_group}}', [
            'id' => $this->primaryKey(),
            'module' => $this->string()->notNull()->defaultValue('admin')->comment('所属模块'),
            'role_level' => $this->integer()->notNull()->comment('角色等级'),
            'title' => $this->string()->comment('用户组名称'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1)->comment('用户组状态 1:正常 0:禁用'),
            'rules' => $this->text()->comment('用户组拥有的规则id， 多个规则","隔开'),
            'notation' => $this->string()->comment('组别描述'),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%auth_group}}');

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190912_055740_auth_group cannot be reverted.\n";

        return false;
    }
    */
}
